#pragma once

#include "Socket.h"
#include "EventPoller.h"

#include "Mutex.h"
using namespace yazi::thread;

#include "ObjectPool.h"
using namespace yazi::utility;


namespace yazi{
namespace socket{

class SocketHandler{
public:
    SocketHandler();
    ~SocketHandler();

    void listen(const string& ip, const int port);
    void attach(Socket* sock);
    void detach(Socket* sock);
    void remove(Socket* sock);
    void handle(int maxconnections, int millseconds);

private:
    EventPoller* m_epoll;
    Socket* m_server;
    ObjectPool<Socket> m_sockpool;
    Mutex m_mutex;
};


}}